import cv2
from surround_view.param_settings import camera_ids
# 假设 param_settings 已经导入并且包含 camera_ids 变量
# from param_settings import camera_ids

# 示例：如果 param_settings 文件中有 camera_ids = [4, 5, 0, 2]
#camera_ids = [4, 5, 0, 2]  # 这里直接赋值作为例子

# image_paths = ["images/front.png", "images/back.png", "images/left.png", "images/right.png"]
image_paths = ["1/front.png", "1/back.png", "1/left.png", "1/right.png"]

for idx, cam_id in enumerate(camera_ids):
    cap = cv2.VideoCapture(cam_id)
    
    if not cap.isOpened():
        print(f"无法打开摄像头 {cam_id}")
        continue
    
    ret, frame = cap.read()
    if ret:
        cv2.imwrite(image_paths[idx], frame)
        print(f"图片已保存为 {image_paths[idx]}")
    else:
        print(f"无法从摄像头 {cam_id} 读取帧")
    
    cap.release()